import http from '@/http'

export default {
  loadInfos(success){
    http.get('product/infos',{},success);
  },
    /**
     * 产品列表
     * @param {number} page  页码
     * @param {Function} success 回调
     */
    list(page, success) {
        http.get('product/list', {
            page: page
        }, success);
    },

    areas(success){
      http.get('area/all', {},success);
    },
    /**
     * 产品检索
     * @param {number} page 页码
     * @param {string} key 关键词
     * @param {Function} success 回调
     */
    search(page, key, success) {
        http.get('product/search', {
            page: page,
            key: key
        }, success);
    },
    /**
     * 添加产品
     * @param {Object} product 产品
     * @param {Function} success 回调
     */
    save(product, success) {
        http.postBody('product/add', product, success)
    },
    /**
     * 更新产品
     * @param {Object} product 产品
     * @param {Function} success 回调
     */
    update(product, success) {
        http.postBody('product/edit', product, success)
    },
    /**
     * 删除产品
     * @param {number} id 产品id
     * @param {Function} success 回调
     */
    delete(id, success) {
        http.get('product/delete/' + id, success);
    }
}
